package com.day21.ClientDemo03;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerDemo {
    public static void main(String[] args) throws IOException {
//创建服务器Socket对象
        ServerSocket ss = new ServerSocket(10000);
        Socket s = ss.accept();
        BufferedReader br = new BufferedReader(new
                InputStreamReader(s.getInputStream()));
        BufferedWriter bw = new BufferedWriter(new FileWriter("myNet\\Copy.java"));
        String line;
        while ((line = br.readLine()) != null) { //等待读取数据
            bw.write(line);
            bw.newLine();
            bw.flush();
        }
        BufferedWriter bwServer = new BufferedWriter(new
                OutputStreamWriter(s.getOutputStream()));
        bwServer.write("文件上传成功");
        bwServer.newLine();
        bwServer.flush();
        bw.close();
        ss.close();
    }
}
